<?php echo $javascript->link('scriptaculous-js-1.8.3/lib/prototype.js'); ?>
<?php echo $javascript->link('scriptaculous-js-1.8.3/src/scriptaculous.js'); ?>
<?php echo $javascript->link('popup/popup.js'); ?>
<div class="blacklists index">
	<h2><?php __('Blacklists');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th>&nbsp;Run</th>
			<th>&nbsp;Date</th>
			<th>&nbsp;Mac</th>
			<th>&nbsp;Cust. NR.</th>
			<th>&nbsp;Problem</th>
			<th>&nbsp;Action</th>
			<th>&nbsp;FutureDate</th>
			<th colspan="2">&nbsp;Comment</th>
	</tr>
	<?php
	$i = 1;
	$counter = 1;
	WHILE($row = mysql_fetch_array($result))
	{
		$class = null;
		if ($i++ % 2 == 0) { $class = ' class="altrow"'; }
		else { $class = ' class="altrow2"'; }
		$div = "field".$counter;
		$modemdiv = "modem".$counter;
		$fd = "fd".$counter;		
	?>
	<tr <?php echo $class;?>>
		<td>&nbsp;<?php echo $row['runid']; ?>&nbsp;</td>
		<td>&nbsp;<?php echo $row['date']; ?>&nbsp;</td>
		<td><?php IF($row["pid"] == 7 && $row['statusname'] == "open") { echo $ajax->link($row['mac'], array('controller' => 'oracles', 'action' => 'getModemStatus', '?' => array('mac' => $row['mac'])), array('update' => $modemdiv)); } ELSE { echo $row['mac']; } ?></td>
		<td><?php IF($row["pid"] == 7 && $row['statusname'] == "open") { echo'<div id="'.$modemdiv.'" name="'.$modemdiv.'"></div>'; } ?>&nbsp;<?php echo $row['account']; ?></td>
		<td>&nbsp;<?php echo $row['problemname']; ?></td>
		<td><div id="<?php echo $div; ?>" name = "<?php echo $div; ?>">&nbsp;
		<?php 
		IF($row['statusname'] == "closed") {
		    echo "swap manually created";
		} 
		elseif($row['statusname'] == "skipped") {
		   echo "skipped";
		} 
		ELSE { 
            echo $ajax->link('Process', array('controller' => 'blacklists', 'action' => 'solve', '?' => array('macid' => $row['mid'], 'runid' => $row['runid'], 'div' => $div, 'problemid' => $row['pid'])), array('update' => $div));
			echo " - "; 
		    echo $ajax->link('Skip', array('controller' => 'blacklists', 'action' => 'skip', '?' => array('macid' => $row['mid'], 'runid' => $row['runid'], 'div' => $div, 'problemid' => $row['pid'])), array('update' => $div));
		} ?>
		</div></td>
		<td>
		  <?php IF($row['statusname'] != "closed" && $row['statusname'] != "skipped") { ?>
		  <form method="post">
        	<input type="text" name="fd" id="<?php echo $fd; ?>" value="<?php IF(is_null($row['futuredated'])) { echo ""; } ELSE { echo date("Y-m-d",strtotime($row['futuredated'])); } ?>">
        	<?php $options = array('url'=> array('controller'=>'blacklists', 'action'=>'fdupdate', '?' => array('blid' => $row['blid'])));
			echo $ajax->observeField($fd, $options); ?>
	      </form>
	      <?php } ?>
		</td> 
		<td align="center">&nbsp;
	  	  <?php
	  		IF($comment->searchForComment($row['blid']) == 0){ ?>
	    		<a href="" onmouseover="popup('<?php echo $comment->getComment($row['blid']); ?>','beige')" onmouseout="kill()">View</a>
	  		<?php  }
	  	  ?>
		</td>
		<td>&nbsp;
	  	  <?php
	    	IF($comment->searchForComment($row['blid']) == 0){
	    		echo $ajax->link('Update', array('controller' => 'blacklists', 'action' => 'add2', '?' => array('blid' => $row['blid'], 'div' => $div, 'stat' => 1)), array('update' => $div));
	    	}
	    	ELSE {
	        	echo $ajax->link('Add', array('controller' => 'blacklists', 'action' => 'add2', '?' => array('blid' => $row['blid'], 'div' => $div, 'stat' => 0)), array('update' => $div));
	    	}
	  	  ?>
	  	</td>
		
	</tr>
<?php $counter++; } ?>
	</table>
	<br><br>
</div>